package com.atguigu.controller;

import com.atguigu.dto.Result;
import com.atguigu.pojo.Schedule;
import com.atguigu.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/schedule")
public class ScheController {
    @Autowired
    ScheduleService scheduleService;
    @GetMapping("/list")
    public Result list() {
        List<Schedule> allSchedule = scheduleService.getAllSchedule();
        return Result.success(allSchedule);
    }
    @PostMapping
    public Result addSchedule(@RequestBody Schedule schedule) {
        boolean b = scheduleService.addSchedule(schedule);
        if (b) {
            return Result.success();
        }
        return Result.error();
    }
}
